using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum ThayDoiQuyDinhBUSResult
    {
        OK,
        TUOITOIDAERROR,
        TUOITOITHIEUERROR,
        THOIHANTHEERROR,
        SONGAYMUONTOIDAERROR,
        SOSACHMUONTOIDAERROR,
        TIENPHATSACHTREERROR,
        DAOERROR
    }

    public class clsThayDoiQuyDinhBUS
    {
        //Fields.
        private clsThayDoiQuyDinhDAO ThayDoiQuyDinhDAO;

        //Constructors.
        public clsThayDoiQuyDinhBUS()
        {
            this.ThayDoiQuyDinhDAO = new clsThayDoiQuyDinhDAO();
        }

        #region Methods

        public ThayDoiQuyDinhBUSResult KiemTraRong(clsThayDoiQuyDinhDTO obj)
        {
            if (obj.TuoiToiDa < 0)
                return ThayDoiQuyDinhBUSResult.TUOITOIDAERROR;
            if (obj.TuoiToiThieu < 0)
                return ThayDoiQuyDinhBUSResult.TUOITOITHIEUERROR;
            if (obj.SoNgayMuonToiDa < 0)
                return ThayDoiQuyDinhBUSResult.SONGAYMUONTOIDAERROR;
            if (obj.SoSachMuonToiDa < 0)
                return ThayDoiQuyDinhBUSResult.SOSACHMUONTOIDAERROR;
            if (obj.ThoiHanThe < 0)
                return ThayDoiQuyDinhBUSResult.THOIHANTHEERROR;
            if (obj.TienPhatSachTre < 0)
                return ThayDoiQuyDinhBUSResult.TIENPHATSACHTREERROR;
            return ThayDoiQuyDinhBUSResult.OK;
        }

        public DataTable DanhSachThayDoiQuyDinh()
        {
            return this.ThayDoiQuyDinhDAO.SelectAll();
        }

        public ThayDoiQuyDinhBUSResult SuaThayDoiQuyDinh(clsThayDoiQuyDinhDTO obj)
        {
            if (!this.ThayDoiQuyDinhDAO.Update(obj))
                return ThayDoiQuyDinhBUSResult.DAOERROR;
            return ThayDoiQuyDinhBUSResult.OK;
        }
        #endregion
    }
}
